package bb.lanxing.databinding.unit;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

public class WeightUnit extends Unit {
    public static float LegalBritishMaxNum = 440.0f;
    public static float LegalBritishMinNum = 60.0f;
    public static float LegalMetricMaxNum = 200.0f;
    public static float LegalMetricMinNum = 30.0f;

    public WeightUnit(String str) {
        super(str, "m");
    }

    public WeightUnit(String str, DecimalFormat decimalFormat) {
        super(str, "m", decimalFormat);
    }

    public WeightUnit(String str, String str2, DecimalFormat decimalFormat) {
        super(str, str2, decimalFormat);
    }

    @Override
    String convertToMetric(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.45359237"));
        this.numberDecimalFormat.setMinimumFractionDigits(0);
        this.valueMetric = this.numberDecimalFormat.format(multiply);
        return this.valueMetric;
    }

    @Override
    String convertToMetric(String str, int i) {
        BigDecimal scale = new BigDecimal(str).multiply(new BigDecimal("0.45359237")).setScale(i, RoundingMode.HALF_UP);
        this.numberDecimalFormat.setMaximumFractionDigits(i);
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueMetric = this.numberDecimalFormat.format(scale);
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str, int i) {
        BigDecimal scale = new BigDecimal(str).multiply(new BigDecimal("2.2046226")).setScale(i, RoundingMode.HALF_UP);
        this.numberDecimalFormat.setMaximumFractionDigits(i);
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueBritish = this.numberDecimalFormat.format(scale);
        return this.valueBritish;
    }

    @Override
    String convertToMetricLB2G(String str, int i) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.45359237"));
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueMetric = this.numberDecimalFormat.format(multiply);
        return this.valueMetric;
    }

    @Override
    String convertToBritish(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("2.2046226"));
        this.numberDecimalFormat.setMinimumFractionDigits(0);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }

    @Override
    String convertToBritishG2LB(String str, int i) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("2204.6226"));
        this.numberDecimalFormat.setMinimumFractionDigits(i);
        this.valueBritish = this.numberDecimalFormat.format(multiply);
        return this.valueBritish;
    }

    @Override
    public String getUnitString(String str) {
        return str.equals("m") ? " kg" : str.equals("f") ? " lb" : " ";
    }
}
